package com.zlx.mall.biz.combo.controller;

import com.zlx.mall.basic.annotations.ValidateToken;
import com.zlx.mall.basic.web.model.BaseRequest;
import com.zlx.mall.basic.web.model.BaseResponse;
import com.zlx.mall.biz.combo.model.GoodsUpgradeResponse;
import com.zlx.mall.biz.combo.service.IComboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author xiatian
 * @Date 2025/3/23 星期日 12:30
 * @注释
 */
@RestController
public class ComboController {
    @Autowired
    private IComboService comboService;

    @PostMapping("/api/combo/list")
    //@ValidateToken
    public BaseResponse list(BaseRequest request) {
        return comboService.list(request.asText("/selectCode"));
    }

    @PostMapping("/api/combo/goods/upgrade")
    public BaseResponse goodsUpgrade(BaseRequest request) {
        List<GoodsUpgradeResponse> responses = comboService.goodsUpgrade(request.asValidLong("/subCategoryId", "二级类目不能为空"));
        return BaseResponse.success(responses);
    }

    // 加购商品
    @PostMapping("/api/combo/goods/match")
    public BaseResponse goodsMatch(BaseRequest request) {
        return comboService.goodsMatch(request.asValidLong("/subCategoryId", "二级类目不能为空"));
    }

}
